<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />
		<title>投放明细</title>
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/css/common.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/css/tag.css" />
		<link rel="stylesheet" type="text/css" 
			href="<%=path%>/js/jquery-ui-1.8.21.custom/css/smoothness/jquery-ui-1.8.21.custom.css" />
		<script type="text/javascript" src="<%=path%>/js/jquery-1.7.2.js"></script>
		<script type="text/javascript"
			src="<%=path%>/js/jquery-ui-1.8.21.custom/js/jquery-ui-1.8.21.custom.min.js"></script>
		<script type="text/javascript" src="<%=path%>/js/form.js"></script>
		<script type="text/javascript" src="<%=path%>/js/public.js"></script>
		<script type="text/javascript" src="<%=path%>/js/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript">
		    $(document).ready(function(){  
			    //禁止退格键 作用于Firefox、Opera    
			    document.onkeypress = banBackSpace;  
			    //禁止退格键 作用于IE、Chrome   
			    document.onkeydown = banBackSpace;
			    
			   var proMedID = '${projectMedium.proMedID}';
			   if(proMedID != null && proMedID != '')
			   {
			      $("#materialInfoisload").val("1");
			      $("#arrangementisload").val("1");
			      $("#chargeisload").val("1");
			      
			      loadPage('initEditBasicInfo.action', {'projectMedium.proMedID': proMedID}, 'initBasicInfo');
			      loadPage('initEditMaterialInfo.action', {'castDetail.proMedID': proMedID}, 'initMaterialInfo');
			      loadPage('initEditArrangementInfo.action', {'projectMedium.proMedID':proMedID, 'castDetail.proMedID':proMedID}, 'initArrangementInfo');
			      loadPage('initEditCharges.action', {'proMedID': proMedID}, 'initCharge');
			      
			      $("#initBasicInfo").show();
			      $("#initMaterialInfo").show();
			      $("#initArrangementInfo").show();
			      $("#initCharge").show();
			      
			      $('#initMaterialInfo_Edu_hidden').show();
			      $('#initMaterialInfo_Edu_show').hide();
			      $('#initArrangementInfo_Edu_hidden').show();
			      $('#initArrangementInfo_Edu_show').hide();
			      $('#initCharge_Edu_hidden').show();
			      $('#initCharge_Edu_show').hide();
			   }
			   else if('1' == '${castDetailstatus}')
			   {
			      loadPage('initInsertBasicInfo.action', {'castDetailstatus': '1', 'projectMedium.projectID':'${projectMedium.projectID}'}, 'initBasicInfo');
			   }
			   else
			   {
			      loadPage('initInsertBasicInfo.action', null, 'initBasicInfo');
			   }
			});
			
			//处理键盘事件 禁止后退键（Backspace）密码或单行、多行文本框除外 
			function banBackSpace(e){
				//alert(event.keyCode)
			    var ev = e || window.event;//获取event对象   
			    var obj = ev.target || ev.srcElement;//获取事件源     
			    var t = obj.type || obj.getAttribute('type');//获取事件源类型     
			    //获取作为判断条件的事件类型 
			    var vReadOnly = obj.readOnly;
			    var vDisabled = obj.disabled;
			    //处理undefined值情况 
			    vReadOnly = (vReadOnly == undefined) ? false : vReadOnly;
			    vDisabled = (vDisabled == undefined) ? true : vDisabled;
			    //当敲Backspace键时，事件源类型为密码或单行、多行文本的，  
			    //并且readOnly属性为true或disabled属性为true的，则退格键失效  
			    var flag1 = ev.keyCode == 8 && (t == "password" || t == "text" || t == "textarea") && (vReadOnly == true || vDisabled == true);
			    //当敲Backspace键时，事件源类型非密码或单行、多行文本的，则退格键失效    
			    var flag2 = ev.keyCode == 8 && t != "password" && t != "text" && t != "textarea";
			    //判断    
			    if (flag2 || flag1) 
			        ev.returnValue = false;//这里如果写 return false 无法实现效果 
			}
			
			function showinfo(container, tagImage, chkFields)
			{
			   var proMedID = $("#chkProMedID").val()
			   if(chkFields == '1')
			   {
			      if(proMedID == null || proMedID == '')
			      {
			          alert("投放明细的基本信息没有保存，不能进行此操作，请先保存基本信息。");
			          return false;
			      }
			   }
			   
			   if(chkFields == '2')
			   {
			      if(proMedID == null || proMedID == '')
			      {
			          alert("投放明细的基本信息没有保存，不能进行此操作，请先保存基本信息。");
			          return false;
			      }
			      
			      if($("#chkArrangement").val() == null || $("#chkArrangement").val() == '')
			      {
			          alert("投放明细的排期未完成，不能进行费用选择，请先进行排期操作。");
			          return false;
			      }
			   }
			   
			   if(container == 'initMaterialInfo' && $("#materialInfoisload").val() != '1')
			   {
			      $("#materialInfoisload").val("1");
			      loadPage('initInsertMaterialInfo.action', {'projectMedium.proMedID': proMedID}, 'initMaterialInfo');
			   }
			   else if(container == 'initArrangementInfo' && $("#arrangementisload").val() != '1')
			   {
			      $("#arrangementisload").val("1");
			      loadPage('initInsertArrangementInfo.action', {'projectMedium.proMedID':proMedID}, 'initArrangementInfo');
			   }
			   else if(container == 'initCharge' && $("#chargeisload").val() != '1')
			   {
			      $("#chargeisload").val("1");
			      loadPage('initCharge.action', {'proMedID':proMedID}, 'initCharge');
			   }
			   
			   $('#' + container).toggle('fast', function(){
			      $('#' + container + '_' + tagImage + '_hidden').toggle();
			      $('#' + container + '_' + tagImage + '_show').toggle();
			   });
			}
			
			function showResult()
			{
			   alert('操作成功！');
			}
		</script>
	</head>

	<body>
		<!-- 顶栏start -->
		<jsp:include page="/jsp/common/top.jsp"></jsp:include> 
		<!-- 顶栏end -->

		<!-- 顶部start -->
		<div id="main">
			<div class="body">
				<!-- 导航菜单start -->
				<jsp:include page="../common/nav.jsp"></jsp:include>
				<!-- 导航菜单end -->
				<div style="padding: 1px 0 3px 5px;">
					<input id="returnbutton" type="button" class="btn-title" value="返回" onclick="window.location.href='mediumCastDetailList.action';"/>
				</div>
				<!-- 主体 -->
				<div class="main_body">
					<input type="hidden" id="materialInfoisload"  name="materialInfoisload" />
					<input type="hidden" id="arrangementisload"  name="arrangementisload" />
					<input type="hidden" id="chargeisload"  name="chargeisload" />
					<ul id="add_div">
						<!-- 基本信息 -->
						<table class="table_header" cellspacing="0" cellpadding="0" border="0">
							<tbody>
								<tr>
									<td style="width: 20px;">
									</td>
									<td valign="middle" align="left">
										基本信息
									</td>
									<td valign="middle" align="right">
										<img id="initBasicInfo_Edu_hidden" hspace="10" align="absmiddle" style="cursor:pointer; display:" onclick="showinfo('initBasicInfo', 'Edu');" src="<%=path%>/images/btn_shrink.gif" />
										<img id="initBasicInfo_Edu_show" hspace="10" align="absmiddle" style="cursor:pointer; display:none" onclick="showinfo('initBasicInfo', 'Edu');" src="<%=path%>/images/btn_spread.gif" />
									</td>
									<td style="width: 20px;">
									</td>
								</tr>
							</tbody>
						</table>
						<div id="initBasicInfo">
						</div>
					    <!-- 物料信息 -->
					    <table class="table_header" cellspacing="0" cellpadding="0" border="0">
							<tbody>
								<tr>
									<td style="width: 20px;">
									</td>
									<td valign="middle" align="left">
										物料信息
									</td>
									<td valign="middle" align="right">
										<img id="initMaterialInfo_Edu_hidden" hspace="10" align="absmiddle" style="cursor:pointer; display:none;" onclick="showinfo('initMaterialInfo', 'Edu', '1');" src="<%=path%>/images/btn_shrink.gif" />
										<img id="initMaterialInfo_Edu_show" hspace="10" align="absmiddle" style="cursor:pointer; display:block;" onclick="showinfo('initMaterialInfo', 'Edu', '1');" src="<%=path%>/images/btn_spread.gif" />
									</td>
									<td style="width: 20px;">
									</td>
								</tr>
							</tbody>
						</table>
					    <div id="initMaterialInfo" style="display: none;">
						</div>
					    <!-- 刊例排期 -->
					    <table class="table_header" cellspacing="0" cellpadding="0" border="0">
							<tbody>
								<tr>
									<td style="width: 20px;">
									</td>
									<td valign="middle" align="left">
										刊例排期
									</td>
									<td valign="middle" align="right">
										<img id="initArrangementInfo_Edu_hidden" hspace="10" align="absmiddle" style="cursor:pointer; display:none;" onclick="showinfo('initArrangementInfo', 'Edu', '1');" src="<%=path%>/images/btn_shrink.gif" />
										<img id="initArrangementInfo_Edu_show" hspace="10" align="absmiddle" style="cursor:pointer; display:block;" onclick="showinfo('initArrangementInfo', 'Edu', '1');" src="<%=path%>/images/btn_spread.gif" />
									</td>
									<td style="width: 20px;">
									</td>
								</tr>
							</tbody>
						</table>
						<div id="initArrangementInfo" style="display: none;">
						</div>
						<!-- 费用信息 -->
					    <table class="table_header" cellspacing="0" cellpadding="0" border="0">
							<tbody>
								<tr>
									<td style="width: 20px;">
									</td>
									<td valign="middle" align="left">
										费用信息
									</td>
									<td valign="middle" align="right">
										<img id="initCharge_Edu_hidden" hspace="10" align="absmiddle" style="cursor:pointer; display:none;" onclick="showinfo('initCharge', 'Edu', '2');" src="<%=path%>/images/btn_shrink.gif" />
										<img id="initCharge_Edu_show" hspace="10" align="absmiddle" style="cursor:pointer; display:block;" onclick="showinfo('initCharge', 'Edu', '2');" src="<%=path%>/images/btn_spread.gif" />
									</td>
									<td style="width: 20px;">
									</td>
								</tr>
							</tbody>
						</table>
						<div id="initCharge" style="display: none;">
						</div>
					</ul>
				</div>
			</div>
		</div>
		<!-- 顶部end -->

		<!-- 底部start -->
		<jsp:include page="/jsp/common/bottom.jsp"></jsp:include> 
	</body>
</html>
